import { BrowserWindow } from 'electron';
import path from 'path'

const winURL = process.env.NODE_ENV === 'development'
    ? `http://localhost:9080/`
    : `file://${__dirname}/index.html`;


class contentWindow {
    constructor(param, contentWindows) {
        this.closeEvent = function () { };
        this.service = param.service;
        this.token = param.token;
        this.project = param.project;
        this.windowId = this.service.serviceId + '-' + this.project.projectId;


        let win = new BrowserWindow({
            title: 'Requester',
            height: 800,
            width: 1280,
            minWidth: 1280,
            minHeight: 800,
            useContentSize: false,
            frame: false,
            show: false,
            icon: path.join(__static, 'logo-256x256.png'),
            webPreferences: {
                nodeIntegration: true,
                webSecurity: false
            }
        });
        win.once('ready-to-show', () => {
            win.show();
        });
        win.loadURL(winURL);
        win.webContents.on('did-finish-load', function () {
            win.webContents.send('routerView', JSON.stringify({
                url: '/main'
            }));
        });
        win.webContents.on('get-window-options', function () {
            win.webContents.send('send-window-options', JSON.stringify(param));
        });

        this.win = win;
    }
    show() {
        this.win.show();
    }
    focus() {
        this.win.focus();
    }
    onClose(event) {
        this.closeEvent = event;
    }
};



export default contentWindow;

